package group;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Spinner;
import org.eclipse.swt.widgets.Text;

public class GroupUsefulFor {
	public GroupUsefulFor() {
		Display display = new Display();
		Shell shell = new Shell(display);
		shell.setSize(600, 400);
		shell.setLayout(new GridLayout(1, true));
		
		final Composite comp=new Composite(shell,SWT.BORDER);
		comp.setLayout(new GridLayout(2,true));
		
		createNVDialogArea(comp);
	
		shell.pack();
		shell.open();

		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
		display.dispose();
	}

	public static void main(String[] args) {
		new GroupUsefulFor();
	}
	
	protected void createNVDialogArea(Composite container) {
		container.setLayout(new GridLayout());
			
		final Composite composite = new Composite(container, SWT.NONE);
		composite.setLayout(new GridLayout(1, false));
		
		
		
		//第一个group放了1行3列
		final Group group = new Group(composite, SWT.NONE);
		group.setText("基本信息");
		group.setLayout(new FormLayout());
		GridData gGridData = new GridData(600, 50);
		group.setLayoutData(gGridData);
		
		//第一列label
		final FormData formlnum = new FormData();
		formlnum.right = new FormAttachment(0, 73);
		formlnum.left = new FormAttachment(0, 18);
		formlnum.top = new FormAttachment(0, 15);
		formlnum.bottom = new FormAttachment(0, 50);
		Label lab3 = new Label(group, SWT.NONE);
		lab3.setText("设备编码");
		lab3.setLayoutData(formlnum);
		
		//第二列文本框
		final FormData formtnum = new FormData();
		formtnum.right = new FormAttachment(0, 225);
		formtnum.left = new FormAttachment(0, 73);
		formtnum.top = new FormAttachment(0, 8);
		formtnum.bottom = new FormAttachment(0, 34);
		final Text textrpuNum = new Text(group, SWT.BORDER);
		textrpuNum.setLayoutData(formtnum);

		//第三列按钮
		Button btnButton = new Button(group, SWT.BORDER);
		final FormData formtbtn = new FormData();
		formtbtn.right = new FormAttachment(0, 265);
		formtbtn.left = new FormAttachment(0, 230);
		formtbtn.top = new FormAttachment(0, 8);
		formtbtn.bottom = new FormAttachment(0, 34);
		btnButton.setLayoutData(formtbtn);
		btnButton.setText("选择");
		
		
		
		//第二个group，2行2列
		final Group groupSvc = new Group(composite, SWT.NONE);
		groupSvc.setText("本地配置");
		groupSvc.setLayout(new FormLayout());
		GridData gdGridData = new GridData(600, 70);
		groupSvc.setLayoutData(gdGridData);

		//第二个group，第一行1列
		final FormData formlpg = new FormData();
		formlpg.right = new FormAttachment(0, 73);
		formlpg.left = new FormAttachment(0, 20);
		formlpg.top = new FormAttachment(0, 17);
		formlpg.bottom = new FormAttachment(0, 37);
		formlpg.height = 15;
		formlpg.width = 100;	
		Label lab13 = new Label(groupSvc, SWT.NONE);
		lab13.setText("信令端口");
		lab13.setLayoutData(formlpg);
		
		//第二个group，第一行2列
		final FormData formtpg = new FormData();
		formtpg.right = new FormAttachment(0, 115);
		formtpg.left = new FormAttachment(0, 75);
		formtpg.top = new FormAttachment(0, 11);
		formtpg.bottom = new FormAttachment(0, 37);
		formtpg.height = 15;
		formtpg.width = 100;
		Spinner sp = new Spinner(groupSvc, SWT.BORDER|SWT.CENTER);
		sp.setLayoutData(formtpg);
		
		//第二个group，第二行1列
		Label labstream = new Label(groupSvc, SWT.NONE);
		labstream.setText("媒体端口");
		final FormData formlstream = new FormData();
		formlstream.right = new FormAttachment(0, 73);
		formlstream.left = new FormAttachment(0, 20);
		formlstream.top = new FormAttachment(0, 47);
		formlstream.bottom = new FormAttachment(0, 66);
		formlstream.height = 15;
		formlstream.width = 100;
		labstream.setLayoutData(formlstream);
		
		//第二个group，第二行2列
		final FormData formtstream = new FormData();
		formtstream.right = new FormAttachment(0, 115);
		formtstream.left = new FormAttachment(0, 75);
		formtstream.top = new FormAttachment(0, 41);
		formtstream.bottom = new FormAttachment(0, 66);
		formtstream.height = 15;
		formtstream.width = 100;
		Spinner sp1 = new Spinner(groupSvc, SWT.BORDER|SWT.CENTER);
		sp1.setLayoutData(formtstream);
	}
}